<template>
	<view class="container">
		<u-toast ref="uToast" />
		<u-navbar :is-back="true" title="处理申请" back-icon-color='#333333' height="50" :border-bottom="false">
		</u-navbar>
		<view class="list">
			<view class="designation">
				<text>教师名称</text>
				<text>{{form.teacher_name}}</text>
			</view>
			<view class="position">
				<text>教师职位</text>
				<text>{{form.teacher_post}}</text>
			</view>
			<view class="leave_time">
				<text>请假时间</text>
				<text>{{form.time}}</text>
			</view>
			<view class="vacate">
				<text>请假时长</text>
				<text>{{form.time_length}}</text>
			</view>
			<view class="leave_reason">
				<text>请假原因</text>
				<text>{{form.reason}}</text>
			</view>
			<view class="handing">
				<text class="results">处理结果</text>
				<view class="toggle">
					<text :style="{color:left_color,background:left_background_color}"
						@click="changeLeftColor">通过</text>
					<text :style="{color:right_color,background:right_background_color}"
						@click="changeRightColor">驳回</text>
				</view>
			</view>
			<view class="remarks">
				<text>处理备注</text>
			</view>
			<view class=""
				style="width:710rpx; height:15rpx; margin-left:20rpx; background:#F2F2F2; border-top-left-radius:12rpx; border-top-right-radius:12rpx;">

			</view>
			<textarea value="" v-model="input_content" placeholder="单行输入"
				style="width:710rpx; height:160rpx; margin-left:20rpx; background:#F2F2F2; text-indent:1em; border-bottom-left-radius:12rpx; border-bottom-right-radius:12rpx;" />
			<view class="" style="width:100%; height:25rpx;">
			</view>
		</view>
		<view class="confirm">
			<view class="verify" @click="handleProgress">
				{{verify}}
			</view>
		</view>
	</view>
</template>

<script>
	import request from '../../request.js'
	export default {
		data() {
			return {
				left_color: '#fff',
				left_background_color: '#2E98FA',
				right_color: '#333333',
				right_background_color: '#F2F2F2',
				input_content: '',
				verify: '确认',
				delivery_obj: {},
				form: {
					progress_id: '',
					progress_type: '',
					teacher_name: '',
					teacher_post: '',
					time_length: '',
					reason: '',
					time: '',
					change_status: 2,
				},
			}
		},
		onLoad(option) {
			if (option.obj) {
				console.log('进来了吗')
				this.delivery_obj = JSON.parse(decodeURIComponent(option.obj));
				this.form.progress_id = this.delivery_obj.progress_id;
				this.form.progress_type = this.delivery_obj.progress_type;
				this.form.teacher_name = this.delivery_obj.teacher_name;
				this.form.teacher_post = this.delivery_obj.teacher_post;
				this.form.time = this.delivery_obj.time;
				this.form.time_length = this.delivery_obj.time_length;
				this.form.reason = this.delivery_obj.reason;
			}
		},
		methods: {
			handleProgress() {
				this.display = false;
				let base_url = uni.getStorageSync('host');
				console.log(base_url);
				let _this = this;
				request({
					url: base_url + 'teacher/progress/handleProgress',
					method: 'post',
					data: {
						progress_id: this.form.progress_id,
						change_status: this.form.change_status
					},
					success(res) {
						if (res.statusCode == 200) {
							console.log(res.data.data);
							_this.$toLink('../approval_flow/approval_flow', {})
						} else {
							_this.$refs.uToast.show({
								title: res.data.message || '系统错误',
								type: 'warning',
							})
						}

					}
				})
			},
			changeLeftColor() {
				if (this.left_background_color == '#2E98FA') {
					this.left_color = '#333333';
					this.left_background_color = '#F2F2F2';
					this.right_color = '#fff';
					this.right_background_color = '#2E98FA';
				} else {
					this.left_color = '#fff';
					this.left_background_color = '#2E98FA';
					this.form.change_status = 2;
					this.right_color = '#333333';
					this.right_background_color = '#F2F2F2';
				}
			},
			changeRightColor() {
				if (this.right_background_color == '#2E98FA') {
					this.right_color = '#333333';
					this.right_background_color = '#F2F2F2';
					this.left_color = '#fff';
					this.left_background_color = '#2E98FA';
				} else {
					this.right_color = '#fff';
					this.right_background_color = '#2E98FA';
					this.form.change_status = 4;
					this.left_color = '#333333';
					this.left_background_color = '#F2F2F2';
				}
			}
		}
	}
</script>

<style lang="scss">
	.container {
		width: 100%;
		overflow: hidden;
		background: #F2F2F2;
		height: 100vh;

		.list {
			width: 100%;
			margin-top: 20rpx;
			background: #fff;

			.designation {
				width: 710rpx;
				margin-left: 20rpx;
				height: 60rpx;
				display: flex;
				justify-content: flex-start;

				text {
					margin-top: 25rpx;
					font-size: 26rpx;

					&:nth-child(1) {
						color: #666666;
						width: 150rpx;
					}

					&:nth-child(2) {
						color: #333333;
					}
				}
			}

			.position {
				width: 710rpx;
				margin-left: 20rpx;
				height: 60rpx;
				display: flex;
				justify-content: flex-start;

				text {
					margin-top: 25rpx;
					font-size: 26rpx;

					&:nth-child(1) {
						color: #666666;
						width: 150rpx;
					}

					&:nth-child(2) {
						color: #333333;
					}
				}
			}

			.leave_time {
				width: 710rpx;
				margin-left: 20rpx;
				height: 60rpx;
				display: flex;
				justify-content: flex-start;

				text {
					margin-top: 25rpx;
					font-size: 26rpx;

					&:nth-child(1) {
						color: #666666;
						width: 150rpx;
					}

					&:nth-child(2) {
						color: #333333;
						width: 150rpx;

					}

					&:nth-child(3) {
						color: #333333;
					}
				}
			}

			.vacate {
				width: 710rpx;
				margin-left: 20rpx;
				height: 60rpx;
				display: flex;
				justify-content: flex-start;

				text {
					margin-top: 25rpx;
					font-size: 26rpx;

					&:nth-child(1) {
						color: #666666;
						width: 150rpx;
					}

					&:nth-child(2) {
						color: #333333;
					}
				}
			}

			.leave_reason {
				width: 710rpx;
				margin-left: 20rpx;
				height: 120rpx;
				display: flex;
				justify-content: flex-start;
				border-bottom: 1px solid #F2F2F2;


				text {
					margin-top: 25rpx;
					font-size: 26rpx;

					&:nth-child(1) {
						color: #666666;
						width: 150rpx;
					}

					&:nth-child(2) {
						color: #333333;
					}
				}
			}

			.handing {
				width: 710rpx;
				margin-left: 20rpx;
				height: 100rpx;
				align-items: center;
				display: flex;
				justify-content: flex-start;

				.results {
					width: 150rpx;
					color: #666666;
					font-size: 26rpx;
				}

				.toggle {
					width: 160rpx;
					height: 40rpx;
					position: relative;

					text {
						&:nth-child(1) {
							border-top-left-radius: 20rpx;
							border-bottom-left-radius: 20rpx;
							background: #2E98FA;
							color: #fff;
							text-align: center;
							line-height: 40rpx;
							height: 40rpx;
							font-size: 20rpx;
							width: 80rpx;
							position: absolute;
							top: 0;
							left: 0;
						}

						&:nth-child(2) {
							border-top-right-radius: 20rpx;
							border-bottom-right-radius: 20rpx;
							background: #F2F2F2;
							color: #333333;
							text-align: center;
							line-height: 40rpx;
							height: 40rpx;
							font-size: 20rpx;
							width: 80rpx;
							position: absolute;
							top: 0;
							left: 80rpx;
						}
					}
				}
			}

			.remarks {
				width: 710rpx;
				margin-left: 20rpx;
				height: 50rpx;
				display: flex;
				justify-content: flex-start;

				text {
					font-size: 26rpx;
					color: #666666;
					width: 150rpx;
				}
			}
		}

		.confirm {
			width: 100%;
			height: 500rpx;
			display: flex;
			justify-content: center;
			align-items: center;

			.verify {
				width: 200rpx;
				height: 60rpx;
				border-radius: 50rpx;
				text-align: center;
				line-height: 60rpx;
				background: linear-gradient(to right, #2C78FE, #32B0FF);
				color: #fff;
				font-size: 30rpx;
			}
		}
	}
</style>
